package cn.dmp.tags

import org.apache.spark.sql.Row

/**
  * Created by Administrator on 2018/4/29.
  */
object Tags4Device extends Tags{
  override def makeTags(args: Any*): Map[String, Int] = {

    val row = args(0).asInstanceOf[Row]
    var tags =Map[String,Int]()

    val ispname = row.getAs[String]("ispname") //运营商
    val netname = row.getAs[String]("networkmannername") //网络类型
    val client = row.getAs[Int]("client") //操作系统

    ispname match {
      case "移动" => tags += "D00030001" -> 1
      case "联通" => tags += "D00030002" -> 1
      case "电信" => tags += "D00030003" -> 1
      case _ => tags += "D00030004" -> 1
    }
    netname match {
      case "WIFI" => tags += "D00020001" -> 1
      case "4G" => tags += "D00020002" -> 1
      case "3G" => tags += "D00020003" -> 1
      case "2G" => tags += "D00020004" -> 1
      case _ => tags += "D00020005" -> 1
    }
    client match {
      case 1 => tags += "D00010001" -> 1
      case 2 => tags += "D00010002" -> 1
      case 3 => tags += "D00010003" -> 1
      case _ => tags += "D00010004" -> 1
    }

    tags
  }
}
